import java.util.Arrays;

public class MyStack {
    public int[] elem;
    public int Usesize;

    public MyStack() {
        this.elem = new int[10];
    }

    public void push(int val) {
        if(ifFull()){
            elem= Arrays.copyOf(elem,elem.length*2);
        }
        elem[Usesize] = val;
        Usesize++;
    }

    public boolean ifFull() {
        return Usesize==elem.length;
    }
    public int pop(){
        if(isemoty()){
            return -1;
        }
        int val=elem[Usesize-1];
        Usesize--;
        return val;
    }

     public boolean isemoty(){
        return Usesize==0;
     }
     public int peek(){
        if(isemoty()){
            return -1;
        }
        return elem[Usesize-1];
     }

}
